package com.med.controller;

import com.med.service.DoctorService;
import com.med.vo.AddDoctorVO;
import com.med.vo.QueryDoctorVO;
import com.med.vo.UpdateDoctorVO;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject: Internet-base d-healthcare
 * @BelongsPackage: com.med.controller
 * @Author: 小龚
 * @CreateTime: 2025-08-13 15:59
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("/doctor")
public class DoctorController extends BaseController {

    private final DoctorService doctorService;


    @Autowired
    public DoctorController(DoctorService doctorService) {
        this.doctorService = doctorService;
    }


    // 获取搜索条件中的所属科室菜单
    @GetMapping("/getDepartmentOptions")
    public AjaxResult getDepartmentOptions() {
        System.out.println("进入函数");
        return AjaxResult.success(doctorService.getDepartmentOptions());
    }


    // 查询医生
    @GetMapping("/getDoctorList")
    public TableDataInfo getDoctorList(QueryDoctorVO vo) {
        startPage();
        System.out.println(vo);
        return getDataTable(doctorService.getDoctorList(vo));
    }

    // 更新医生的状态
    @PutMapping("/updateDoctorStatus/{doctorId}/{doctorAdminId}")
    public AjaxResult updateDoctorStatus(@PathVariable Integer doctorId, @PathVariable Integer doctorAdminId) {
        System.out.println(doctorId);
        System.out.println(doctorAdminId);
        return AjaxResult.success(doctorService.updateDoctorStatus(doctorId, doctorAdminId));
    }

    // 删除医生
    @DeleteMapping("/deleteDoctor/{doctorId}")
    public AjaxResult deleteDoctor(@PathVariable Integer doctorId) {
        System.out.println(doctorId);
        return AjaxResult.success(doctorService.deleteDoctor(doctorId));
    }

    // 添加医生
    @PostMapping("/addDoctor")
    public AjaxResult addDoctor(@RequestBody AddDoctorVO vo) {
        System.out.println(vo);
        return AjaxResult.success(doctorService.addDoctor(vo));
    }

    // 修改医生
    @PostMapping("/updateDoctor")
    public AjaxResult updateDoctor(@RequestBody UpdateDoctorVO vo) {
        System.out.println(vo);
        return AjaxResult.success(doctorService.updateDoctor(vo));
    }
}
